home *** CD-ROM | disk | FTP | other *** search
-
- CCC C Source Code PrettyPrinter v1.0
-
-
-
- CCC - A C Source Code Prettyprinter
-
- Version 1.0 September, 1986
-
- Copyright (C) 1986 by
-
- Raul Escobar
- 26 Laurel Creek Lane
- Laguna Hills, CA 92653
-
-
-
- PURPOSE:
-
-
- This program reads a C source file, and checks for mismatched
- parentheses, comments and curly braces. It will print the file
- to either the console (default), the printer (-p flag) or a
- disk file with the same name as the source file, and ".CCC"
- extention (-o flag). Curly braces are matched visually by
- drawing lines between opening and closing braces down the left
- side of the page, allowing easy spotting of structures and errors.
- These can either be drawn using IBM Graphic characters, or,
- in case your printer doesn't support them, standard ASCII
- characters (-a flag). The program will optionally provide line
- numbers (-n flag) and page breaks with a header on each page
- when you specify a page length (-l n flag). The program also
- wraps lines at 80 characters unless a page width is specified
- (-w n flag), and expands tabs to every fourth space unless
- a tab width is specified (-T n flag). You may use any com-
- bination of flags, except -o and -p together. Note that the
- space between the flag and the number (n) is required.This
- program preserves the users format, and does not impose its own
- structure on the program.
-
-
- FORMAT:
-
-
- CCC filename [-A] [-L n] [N] [-O] [-P] [-T n] [-W n]
- where filename is the C source file.
- -A uses ASCII (defaults to IBM graphic characters).
- -L set page length (defaults to no page breaks).
- -N inserts line numbers.
- -O writes to the file filename.CCC.
- -P sends output to printer.
- -T sets tabs every n spaces (defaults to 4).
- -W sets page width to n columns (defaults to 80).
-
-
- CCC C Source Code PrettyPrinter v1.0
-
-
-
-
- EXAMPLE:
-
-
- Using the following program as input:
-
-
- /*
- * S I N G L E I T
- *
- */
- #include "stdio.h"
-
- #define CR 13
- #define LF 10
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- FILE *ifp,*ofp;
- char c,c1,c2,c3,c4,buf[132];
-
- if ((ifp=fopen(argv[1],"r"))==NULL) usage();
- if ((ofp=fopen(argv[2],"w"))==NULL) usage();
-
- while ((c=fgets(buf,132,ifp))!=NULL) {
- if (buf[0]==CR||buf[0]==LF)
- ;
- else
- fputs(buf,ofp);
- }
- fcloseall();
- }
-
- usage()
- {
- printf("\nUsage is: singleit <infile> <outfile>");
- exit(0);
- }
-
-
-
- CCC C Source Code PrettyPrinter v1.0
-
-
-
-
- issuing the command "CCC singleit.c -n -l 60 -w 60"
- produces the console listing:
-
-
- ┌─────────────────────────────────────────────────────────┐
- │ File: singleit.c page 1 │
- └─────────────────────────────────────────────────────────┘
-
- 1: /*
- 2: * S I N G L E I T
- 3: *
- 4: */
- 5: #include "stdio.h"
- 6:
- 7: #define CR 13
- 8: #define LF 10
- 9:
- 10: main(argc,argv)
- 11: int argc;
- 12: char *argv[];
- 13:┌─ {
- 14:│ FILE *ifp,*ofp;
- 15:│ char c,c1,c2,c3,c4,buf[132];
- 16:│
- 17:│ if ((ifp=fopen(argv[1],"r"))==NULL) usage();
- 18:│ if ((ofp=fopen(argv[2],"w"))==NULL) usage();
- 19:│
- 20:│ ┌─ while ((c=fgets(buf,132,ifp))!=NULL) {
- 21:│ │ if (buf[0]==CR||buf[0]==LF)
- 22:│ │ ;
- 23:│ │ else
- 24:│ │ fputs(buf,ofp);
- 25:│ └─ }
- 26:│ fcloseall();
- 27:└─ }
- 28:
- 29: usage()
- 30:┌─ {
- 31:│ printf("\nUsage is: singleit <infile> <outfil
- │ e>");
- 32:│ exit(0);
- 33:└─ }
- 34:
-
-
- CCC C Source Code PrettyPrinter v1.0
-
-
-
- and issuing the command "CCC singleit.c -a -o"
- produces a disk file called "SINGLEIT.CCC" containing:
-
- /*
- * S I N G L E I T
- *
- */
- #include "stdio.h"
-
- #define CR 13
- #define LF 10
-
- main(argc,argv)
- int argc;
- char *argv[];
- +- {
- | FILE *ifp,*ofp;
- | char c,c1,c2,c3,c4,buf[132];
- |
- | if ((ifp=fopen(argv[1],"r"))==NULL) usage();
- | if ((ofp=fopen(argv[2],"w"))==NULL) usage();
- |
- | +- while ((c=fgets(buf,132,ifp))!=NULL) {
- | | if (buf[0]==CR||buf[0]==LF)
- | | ;
- | | else
- | | fputs(buf,ofp);
- | +- }
- | fcloseall();
- +- }
-
- usage()
- +- {
- | printf("\nUsage is: singleit <infile> <outfile>");
- | exit(0);
- +- }
-
-
- CCC C Source Code PrettyPrinter v1.0
-
-
-
-
- REMARKS:
-
-
-
- This is a public domain "freeware" program. You are encouraged
- to use it, copy it and give it to your friends. You are also
- encouraged to communicate any problems, bugs, questions, sug-
- gestions, requests for enhancements, etc. Donations are also
- accepted, and will enable you to receive future updates and
- other programs written by the author. Please address all
- correspondence to:
-
-
-
- Raul Escobar
- 26 Laurel Creek Lane
- Laguna Hills, CA 92653
-
-
-
- Possible future enhancements include:
-
- o Outlining of keyword control structures
- o Cross reference generation
- o processing of #include files
- o PASCAL version
- o BASIC version
-